//
// Created by 123 on 2025/1/7.
//
#include "vector"
#include "algorithm"
#include "iostream"

using namespace std;

class Person{
public:
    string name;
    int age;
public:
    Person(string name,int age){
        this->name = name;
        this->age=age;
    }
};

void test1(){
    vector<Person> v;
    Person p1("aaa",111);
    Person p2("bbb",222);
    v.push_back(p1);
    v.push_back(p2);
    v.push_back(Person("ccc",333));
    v.push_back(Person("ddd",444));

    for(vector<Person>::iterator it=v.begin();it != v.end();it++){
        cout << "name=" << (*it).name << " age:" << (*it).age << endl;
    }
}

void test2(){
    vector<Person*> v;
    Person p1("aaaa",1111);
    Person p2("bbbb",2222);
    Person p3("cccc",3333);
    Person p4("dddd",4444);
    v.push_back(&p1);
    v.push_back(&p2);
    v.push_back(&p3);
    v.push_back(&p4);
//    for (Person* p:v) {
//        cout << "name=" << (*p).name << " age=" << (*p).age << endl;
//        cout << "name=" << p->name << " age=" << p->age << endl;
//    }
    for(vector<Person*>::iterator it=v.begin();it != v.end();it++){
        Person* p = *it;
        cout << "nae:" << p->name << " ag:" << (*p).age << endl;
    }
}

int main110(){
    test1();
    test2();
    return 0;
}